import { checkIfLogin } from '../../utils/check'
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const tempUserInfo = app.globalData.userInfo || wx.getStorageSync('userInfo') || {}
    this.setData({
      userInfo: tempUserInfo
    })
  },

  onShow(){
    checkIfLogin()
    const tempUserInfo = app.globalData.userInfo || wx.getStorageSync('userInfo') || {}
    this.setData({
      userInfo: tempUserInfo
    })
  },

  handleExit(){
    // wx.removeStorageSync('token')
    // wx.removeStorageSync('userInfo')
    wx.clearStorage()
    app.globalData.userInfo = null
    wx.switchTab({
      url: '/pages/profile/profile',
    })
  }
  

})